//决斗
#include<bits/stdc++.h>
using namespace std;

int n;
int a[100005];

int kp(int m,int n){
	if(m>n) return m>n;
	else return m<n;
}

int main(){
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		kp(a[i],a[i+1]);
		cout<<a[i]<<' ';
	}

	return 0;
}
